using System;

namespace TrueCode.Core.Validation
{
  public static partial class Validate
  {
    [AttributeUsageAttribute( AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true )]
    public class MaxLengthAttribute : ValidateAttribute
    {
      private readonly int _maxLength;

      public MaxLengthAttribute( int maxLength )
      {
        _maxLength = maxLength;
      }

      public MaxLengthAttribute( int maxLength, Type exceptionType ) : base( exceptionType )
      {
        _maxLength = maxLength;
      }

      public MaxLengthAttribute( int maxLength, Type exceptionType, params object[] arguments ) : base( exceptionType, arguments )
      {
        _maxLength = maxLength;
      }

      public int MaxLength
      {
        get { return _maxLength; }
      }
    }
  }
}